package com.study.talk.utils.extras

import android.content.Intent
import androidx.annotation.AnyThread
import androidx.annotation.DoNotInline
import androidx.appcompat.app.AppCompatActivity
import com.study.common.ToastUtil

@AnyThread
fun AppCompatActivity.showToast(msg: String) {
    ToastUtil.showToast(this, msg)
}

fun <T : AppCompatActivity> AppCompatActivity.start(target: Class<T>, params: (Intent) -> Unit) {
    val intent = Intent(this, target)
    params(intent)
    startActivity(intent)
}

fun <T : AppCompatActivity> AppCompatActivity.start(target: Class<T>) {
    startActivity(Intent(this, target))
}

fun AppCompatActivity.getStrParam(key: String): String {
    return intent.getStringExtra(key) ?: ""
}

fun AppCompatActivity.getIntParam(key: String): Int {
    return intent.getIntExtra(key, -1)
}
